package com.dehui.traders.ui.viewmodle;

import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.SparseArray;

import com.dehui.traders.R;
import com.dehui.traders.bean.ConstantTest;
import com.dehui.traders.kchart.DataParse;
import com.dehui.traders.kchart.MinutesBean;
import com.dehui.traders.kchart.MyBottomMarkerView;
import com.dehui.traders.kchart.MyCombinedChart;
import com.dehui.traders.kchart.MyCombinedChartX;
import com.dehui.traders.kchart.MyHMarkerView;
import com.dehui.traders.kchart.MyLeftMarkerView;
import com.dehui.traders.kchart.MyXAxis;
import com.dehui.traders.kchart.MyYAxis;
import com.dehui.traders.kchart.PriceManager;
import com.dehui.traders.ui.activity.MainActivity;
import com.dehui.traders.ui.fragment.BuySellFragment;
import com.dehui.traders.ui.fragment.FreightSpaceFragment;
import com.dehui.traders.ui.fragment.SmartChooseStocksFragment;
import com.dehui.traders.ui.fragment.TrendFragment;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.LimitLine;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.CombinedData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.ToastUtils;

/**
 * Created by hqq on 18.3.29.
 */

public class HomeViewModel extends BaseViewModel{

    public BindingCommand trendOnClickCommand = new BindingCommand(()->{
        startContainerActivity(TrendFragment.class.getCanonicalName());
    });

    public BindingCommand chooseStocksOnClickCommand = new BindingCommand(()->{
        startContainerActivity(SmartChooseStocksFragment.class.getCanonicalName());
    });

    public BindingCommand buySellOnClickCommand = new BindingCommand(()->{
        startContainerActivity(BuySellFragment.class.getCanonicalName());
    });

    public BindingCommand positionsOnClickCommand = new BindingCommand(()->{
        startContainerActivity(FreightSpaceFragment.class.getCanonicalName());
    });

    private DataParse mData;

    public HomeViewModel(Context context) {
        super(context);
    }

    public void initChart(MyCombinedChartX mChartVolume) {
        getOffLineData();
        PriceManager.getInstange().initPrice(context,mChartVolume,mData);
    }

    private void getOffLineData() {
           /*方便测试，加入假数据*/
        mData = new DataParse();
        JSONObject object = null;
        try {
            object = new JSONObject(ConstantTest.MINUTESURL);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        mData.parseMinutes(object);
    }

    public void changeChart() {
        PriceManager.getInstange().changeData();
    }


}
